package org.smile.db.sql.page;

/**
 * oracle分页方言
 * @author Administrator
 *
 */
public class OracleDialectPage implements DialectPage {

	private String sql;
	
	public OracleDialectPage(String sql){
		this.sql=sql;
	}
	
	public String getCountSql() {
		return "SELECT COUNT(*) FROM ("+sql+") COUNT_TABLE_T";
	}
	
	public String getDataSql(int page,int size) {
		int firstRow=(page-1)*size;
		int endRow=firstRow+size;
		return "SELECT * FROM(SELECT DATA_TABLE_T.*, rownum ROW_NUM FROM("+sql+") DATA_TABLE_T WHERE rownum <="+endRow+") WHERE ROW_NUM >"+firstRow;
	}

}
